#include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
char a[maxn][maxn];

bool find_square(int n, int m) {
	for (int i=1; i<=n - 3; i++) {
		for (int j=1; j<=m - 3; j++) {
			if (strncmp(a[i] + j, "0000", 4) == 0
					&& strncmp(a[i+1] + j, "0110", 4) == 0
					&& strncmp(a[i+2] + j, "0110", 4) == 0
					&& strncmp(a[i+3] + j, "0000", 4) == 0) {
						return true;
			} 
		}
	}
	return false;
}
int main() {
	int grp;
	cin >> grp;
	for (int g=1; g<=grp; g++) {
		int n, m;
		cin >> n >> m;
		for(int i=1; i<=n; i++) {
			cin >> a[i] + 1;
		}
		bool is_find = find_square(n, m);
		if (is_find) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
		memset(a, '\0', sizeof(a));
	}
	return 0;
}
